package cn.com.ethos.search.query;

public abstract class Response {
	public int status = 1;
	
	protected static final String CRLF = "\r\n";
	
	/**
	 * {header} int
	 * 
	 * {body}
	 */
	public String serialize() {
		
		StringBuffer str = new StringBuffer();
		str.append(status);
		str.append(CRLF);
		str.append(CRLF);
		str.append(this.getBody());
		str.append(CRLF);
		str.append(CRLF);
		
		return str.toString();
	}
	
	protected String getSimpleExceptionBody(Exception ex) {
		return "{msg:'"+ex.getMessage().replace("'","\\'")+"'}";
	}
	
	protected abstract String getBody();
}
